<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="./vue.js"></script>
</head>

<body>
  <div id="app">
  </div>
  <script>


    var cache = {
      add(key, value) {
        if (localStorage) {
          localStorage.setItem(key, value)
        } else {
          //...
        }
      },
      remove(key) {
        if (localStorage) {
          localStorage.removeItem(key)
        } else {
          //...
        }
      }
    }

    var MyCache = {
      //v:实际上就是Vue
      install: (v) => {
        // return cache;
        v.prototype.$cache=cache;
      }
    }

    Vue.use(MyCache)

    var vm = new Vue({
      el: "#app",
      mounted(){
        this.$cache.add('name','admin')
        console.log(this.$cache)
      }
    })

  </script>
</body>

</html>